package com.jsh.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jsh.entity.ShopOrder;
import com.jsh.IShopOrderService;
import com.jsh.uitls.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jsh
 * @since 2022-11-16
 */
@RestController
@RequestMapping("/shop-order")
@Api(value = "商品订单信息接口", tags = "商品订单接口")
public class ShopOrderController {

    @Autowired
    private IShopOrderService iShopOrderService;

    @RequestMapping("/order/find")
    @ApiOperation("根据用户id查询")
    public CommonResult selectById(Integer id){
        QueryWrapper<ShopOrder> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_Id",id);
        List<ShopOrder> list = iShopOrderService.list(queryWrapper);
        return CommonResult.ok(list);
    }
    @RequestMapping("/order/save")
    @ApiOperation("添加订单信息")
    public CommonResult addOrder(@RequestBody ShopOrder shopOrder){
        this.iShopOrderService.save(shopOrder);
        return CommonResult.ok();
    }

}

